define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/gen/index' + location.search,
                    // add_url: 'order/gen/add',
                    // edit_url: 'order/gen/edit',
                    del_url: 'order/gen/del',
                    multi_url: 'order/gen/multi',
                    import_url: 'order/gen/import',
                    table: 'order_gen',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'user_id', title: __('User_id')},
                        {field: 'order_sn', title: __('Order_sn'), operate: 'LIKE'},
                        // {field: 'anchor_id', title: __('Anchor_id')},
                        {field: 'user_nickname', title: __('用户昵称')},
                        {field: 'user_mobile', title: __('用户手机号')},
                        {field: 'anchor_nickname', title: __('主播昵称')},
                        {field: 'order_id', title: __('Order_id'),visible: false},
                        {field: 'place_order_sn', title: __('跟的订单订单号')},
                        {field: 'orderpro_id', title: __('Orderpro_id'),visible: false},
                        // {field: 'board_custom', title: __('Board_custom')},
                        // {field: 'exit_custom', title: __('Exit_custom')},
                        // {field: 'end_exit_custom', title: __('End_exit_custom')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'num', title: __('Num'), operate:'BETWEEN'},
                        // {field: 'alr_num', title: __('Alr_num'), operate:'BETWEEN'},
                        {field: 'remain_num', title: __('Remain_num'), operate:'BETWEEN'},
                        {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
                        // {field: 'status', title: __('Status')},
                        {
                            field: 'status',
                            title: __('订单状态'),
                            formatter: Table.api.formatter.normal,
                            searchList: {"0": "上车中", "1": "上车完成"}
                        },
                        {field: 'gen_guard', title: __('Gen_guard'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
